<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCouponsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupon', function (Blueprint $table) {
            $table->increments('coupon_id')->comment('优惠券id 主键自增');
            $table->string('title',255)->nullable()->comment('优惠券名称');
            $table->string('code',45)->nullable()->comment('优惠券券码');
            $table->enum('send_type',['1','2'])->default('1')->comment(' 1：会员领取 2：系统自动发放');
            $table->integer('rule_id')->comment('coupon_rule表的外键');
            $table->integer('send_num')->default(0)->comment('发放数');
            $table->integer('get_num')->default(0)->comment('领取数');
            $table->integer('use_num')->default(0)->comment('使用数');
            $table->integer('start_time')->nullable()->comment('开始时间的时间戳');
            $table->integer('end_time')->nullable()->comment('结束时间的时间戳');
            $table->tinyInteger('disabled')->default(0)->comment('是否删除 0-否 1-是');
            $table->enum('status',['9','5','4','3','2','1','0'])->default(0)->comment('0：准备中1：待审核； 2：待生效；3：已生效；4：已完成；5：中止  9：已作废');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupon');
    }
}
